package com.me.bbs.common;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author Liming Wang
 * @Description
 * @Create 2023/1/31 19:23
 */
public enum BanDuration {

    Day(1,"24小时", 24),
    Week(2,"一周", 24 * 7),
    Month(3,"30天", 24 * 7 * 30),
    HalfAYear(4,"六个月", 24 * 7 * 30 * 6),
    Year(5,"一年", 24 * 7 * 30 * 12),
    Permanent(6,"永久", 24 * 7 * 30 * 12 * 99);
    private final String detail;
    private final Integer code;

    private final Integer hours;

    BanDuration(Integer code, String s, Integer hours) {
        this.detail = s;
        this.code = code;
        this.hours = hours;
    }

    public Integer getHours() {
        return hours;
    }
    public String getDetail() {
        return detail;
    }

    public Integer getCode() {
        return code;
    }

    public static BanDuration getBanDurationByCode(Integer code) {
        return Arrays.stream(BanDuration.values()).filter(v -> Objects.equals(v.getCode(), code)).findFirst().orElse(null);
    }
}
